namespace DotNetNuke.UI.UserControls
{
    using DotNetNuke.Common.Lists;
    using DotNetNuke.Entities.Portals;
    using DotNetNuke.Framework;
    using DotNetNuke.Security;
    using DotNetNuke.Services.Exceptions;
    using DotNetNuke.Services.Localization;
    using DotNetNuke.UI.WebControls;
    using Microsoft.VisualBasic;
    using Microsoft.VisualBasic.CompilerServices;
    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.Diagnostics;
    using System.Runtime.CompilerServices;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;

    /// -----------------------------------------------------------------------------
    /// <summary>
    /// The Address UserControl is used to manage User Addresses
    /// </summary>
    /// <remarks>
    /// </remarks>
    /// <history>
    /// [cnurse]	10/08/2004	Updated to reflect design changes for Help, 508 support
    /// and localisation
    /// </history>
    /// -----------------------------------------------------------------------------
    public class Address : UserControlBase
    {
        private static List<WeakReference> __ENCList = new List<WeakReference>();
        //("cboCountry")]
        private CountryListBox _cboCountry;
        //("cboRegion")]
        private DropDownList _cboRegion;
        private string _Cell;
        //("chkCell")]
        private CheckBox _chkCell;
        //("chkCity")]
        private CheckBox _chkCity;
        //("chkCountry")]
        private CheckBox _chkCountry;
        //("chkFax")]
        private CheckBox _chkFax;
        //("chkPostal")]
        private CheckBox _chkPostal;
        //("chkRegion")]
        private CheckBox _chkRegion;
        //("chkStreet")]
        private CheckBox _chkStreet;
        //("chkTelephone")]
        private CheckBox _chkTelephone;
        private string _City;
        private string _ControlColumnWidth;
        private string _Country;
        private string _CountryData;
        private string _Fax;
        private string _LabelColumnWidth;
        private int _ModuleId;
        private string _Postal;
        private string _Region;
        private string _RegionData;
        private bool _ShowCell;
        private bool _ShowCity;
        private bool _ShowCountry;
        private bool _ShowFax;
        private bool _ShowPostal;
        private bool _ShowRegion;
        private bool _ShowStreet;
        private bool _ShowTelephone;
        private bool _ShowUnit;
        private int _StartTabIndex;
        private string _Street;
        private string _Telephone;
        private string _Unit;
        protected Label lblCellRequired;
        protected Label lblCityRequired;
        protected Label lblCountryRequired;
        protected Label lblFaxRequired;
        protected Label lblPostalRequired;
        protected Label lblRegion;
        protected Label lblRegionRequired;
        protected Label lblStreetRequired;
        protected Label lblTelephoneRequired;
        private string MyFileName;
        protected LabelControl plCell;
        protected LabelControl plCity;
        protected LabelControl plCountry;
        protected LabelControl plFax;
        protected LabelControl plPostal;
        protected LabelControl plRegion;
        protected LabelControl plStreet;
        protected LabelControl plTelephone;
        protected LabelControl plUnit;
        protected HtmlTableRow rowCell;
        protected HtmlTableRow rowCity;
        protected HtmlTableRow rowCountry;
        protected HtmlTableRow rowFax;
        protected HtmlTableRow rowPostal;
        protected HtmlTableRow rowRegion;
        protected HtmlTableRow rowStreet;
        protected HtmlTableRow rowTelephone;
        protected HtmlTableRow rowUnit;
        protected TextBox txtCell;
        protected TextBox txtCity;
        protected TextBox txtFax;
        protected TextBox txtPostal;
        protected TextBox txtRegion;
        protected TextBox txtStreet;
        protected TextBox txtTelephone;
        protected TextBox txtUnit;
        protected RequiredFieldValidator valCell;
        protected RequiredFieldValidator valCity;
        protected RequiredFieldValidator valCountry;
        protected RequiredFieldValidator valFax;
        protected RequiredFieldValidator valPostal;
        protected RequiredFieldValidator valRegion1;
        protected RequiredFieldValidator valRegion2;
        protected RequiredFieldValidator valStreet;
        protected RequiredFieldValidator valTelephone;

        public Address()
        {
            base.Load += new EventHandler(this.Page_Load);
            base.Init += new EventHandler(this.Page_Init);
            List<WeakReference> refObjectHelperL0 = __ENCList;
            lock (refObjectHelperL0)
            {
                __ENCList.Add(new WeakReference(this));
            }
            this._LabelColumnWidth = "";
            this._ControlColumnWidth = "";
            this._StartTabIndex = 1;
            this._ShowStreet = true;
            this._ShowUnit = true;
            this._ShowCity = true;
            this._ShowCountry = true;
            this._ShowRegion = true;
            this._ShowPostal = true;
            this._ShowTelephone = true;
            this._ShowCell = true;
            this._ShowFax = true;
            this._CountryData = "Text";
            this._RegionData = "Text";
            this.MyFileName = "Address.ascx";
        }

        private void cboCountry_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                this.Localize();
            }
            catch (Exception exception1)
            {
                
                Exception exc = exception1;
                DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(this, exc);
                
            }
        }

        private void chkCell_CheckedChanged(object sender, EventArgs e)
        {
            try
            {
                this.UpdateRequiredFields();
            }
            catch (Exception exception1)
            {
                
                Exception exc = exception1;
                DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(this, exc);
                
            }
        }

        private void chkCity_CheckedChanged(object sender, EventArgs e)
        {
            try
            {
                this.UpdateRequiredFields();
            }
            catch (Exception exception1)
            {
                
                Exception exc = exception1;
                DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(this, exc);
                
            }
        }

        private void chkCountry_CheckedChanged(object sender, EventArgs e)
        {
            try
            {
                this.UpdateRequiredFields();
            }
            catch (Exception exception1)
            {
                
                Exception exc = exception1;
                DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(this, exc);
                
            }
        }

        private void chkFax_CheckedChanged(object sender, EventArgs e)
        {
            try
            {
                this.UpdateRequiredFields();
            }
            catch (Exception exception1)
            {
                
                Exception exc = exception1;
                DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(this, exc);
                
            }
        }

        private void chkPostal_CheckedChanged(object sender, EventArgs e)
        {
            try
            {
                this.UpdateRequiredFields();
            }
            catch (Exception exception1)
            {
                
                Exception exc = exception1;
                DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(this, exc);
                
            }
        }

        private void chkRegion_CheckedChanged(object sender, EventArgs e)
        {
            try
            {
                this.UpdateRequiredFields();
            }
            catch (Exception exception1)
            {
                
                Exception exc = exception1;
                DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(this, exc);
                
            }
        }

        private void chkStreet_CheckedChanged(object sender, EventArgs e)
        {
            try
            {
                this.UpdateRequiredFields();
            }
            catch (Exception exception1)
            {
                
                Exception exc = exception1;
                DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(this, exc);
                
            }
        }

        private void chkTelephone_CheckedChanged(object sender, EventArgs e)
        {
            try
            {
                this.UpdateRequiredFields();
            }
            catch (Exception exception1)
            {
                
                Exception exc = exception1;
                DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(this, exc);
                
            }
        }

        [DebuggerStepThrough]
        private void InitializeComponent()
        {
        }

        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Localize correctly sets up the control for US/Canada/Other Countries
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <history>
        /// [cnurse]	10/08/2004	Updated to reflect design changes for Help, 508 support
        /// and localisation
        /// </history>
        /// -----------------------------------------------------------------------------
        private void Localize()
        {
            string countryCode = this.cboCountry.SelectedItem.Value;
            ListController ctlEntry = new ListController();
            string listKey = "Country." + countryCode;
            ListEntryInfoCollection entryCollection = ctlEntry.GetListEntryInfoCollection("Region", "", listKey);
            if (entryCollection.Count != 0)
            {
                this.cboRegion.Visible = true;
                this.txtRegion.Visible = false;
                DropDownList refObjectHelperL0 = this.cboRegion;
                refObjectHelperL0.Items.Clear();
                refObjectHelperL0.DataSource = entryCollection;
                refObjectHelperL0.DataBind();
                this.cboRegion.Items.Insert(0, new ListItem("<" + DotNetNuke.Services.Localization.Localization.GetString("Not_Specified", "~/App_GlobalResources/SharedResources.resx") + ">", ""));
                refObjectHelperL0 = null;
                if (countryCode.ToLower() == "us")
                {
                    this.valRegion1.Enabled = true;
                    this.valRegion2.Enabled = false;
                    this.valRegion1.ErrorMessage = DotNetNuke.Services.Localization.Localization.GetString("StateRequired", DotNetNuke.Services.Localization.Localization.GetResourceFile(this, this.MyFileName));
                    this.plRegion.Text = DotNetNuke.Services.Localization.Localization.GetString("plState", DotNetNuke.Services.Localization.Localization.GetResourceFile(this, this.MyFileName));
                    this.plRegion.HelpText = DotNetNuke.Services.Localization.Localization.GetString("plState.Help", DotNetNuke.Services.Localization.Localization.GetResourceFile(this, this.MyFileName));
                    this.plPostal.Text = DotNetNuke.Services.Localization.Localization.GetString("plZip", DotNetNuke.Services.Localization.Localization.GetResourceFile(this, this.MyFileName));
                    this.plPostal.HelpText = DotNetNuke.Services.Localization.Localization.GetString("plZip.Help", DotNetNuke.Services.Localization.Localization.GetResourceFile(this, this.MyFileName));
                }
                else
                {
                    this.valRegion1.ErrorMessage = DotNetNuke.Services.Localization.Localization.GetString("ProvinceRequired", DotNetNuke.Services.Localization.Localization.GetResourceFile(this, this.MyFileName));
                    this.plRegion.Text = DotNetNuke.Services.Localization.Localization.GetString("plProvince", DotNetNuke.Services.Localization.Localization.GetResourceFile(this, this.MyFileName));
                    this.plRegion.HelpText = DotNetNuke.Services.Localization.Localization.GetString("plProvince.Help", DotNetNuke.Services.Localization.Localization.GetResourceFile(this, this.MyFileName));
                    this.plPostal.Text = DotNetNuke.Services.Localization.Localization.GetString("plPostal", DotNetNuke.Services.Localization.Localization.GetResourceFile(this, this.MyFileName));
                    this.plPostal.HelpText = DotNetNuke.Services.Localization.Localization.GetString("plPostal.Help", DotNetNuke.Services.Localization.Localization.GetResourceFile(this, this.MyFileName));
                }
                this.valRegion1.Enabled = true;
                this.valRegion2.Enabled = false;
            }
            else
            {
                this.cboRegion.ClearSelection();
                this.cboRegion.Visible = false;
                this.txtRegion.Visible = true;
                this.valRegion1.Enabled = false;
                this.valRegion2.Enabled = true;
                this.valRegion2.ErrorMessage = DotNetNuke.Services.Localization.Localization.GetString("RegionRequired", DotNetNuke.Services.Localization.Localization.GetResourceFile(this, this.MyFileName));
                this.plRegion.Text = DotNetNuke.Services.Localization.Localization.GetString("plRegion", DotNetNuke.Services.Localization.Localization.GetResourceFile(this, this.MyFileName));
                this.plRegion.HelpText = DotNetNuke.Services.Localization.Localization.GetString("plRegion.Help", DotNetNuke.Services.Localization.Localization.GetResourceFile(this, this.MyFileName));
                this.plPostal.Text = DotNetNuke.Services.Localization.Localization.GetString("plPostal", DotNetNuke.Services.Localization.Localization.GetResourceFile(this, this.MyFileName));
                this.plPostal.HelpText = DotNetNuke.Services.Localization.Localization.GetString("plPostal.Help", DotNetNuke.Services.Localization.Localization.GetResourceFile(this, this.MyFileName));
            }
            if (this.lblRegionRequired.Text == "")
            {
                this.valRegion1.Enabled = false;
                this.valRegion2.Enabled = false;
            }
        }

        private void Page_Init(object sender, EventArgs e)
        {
            this.InitializeComponent();
        }

        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Page_Load runs when the control is loaded
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <history>
        /// [cnurse]	10/08/2004	Updated to reflect design changes for Help, 508 support
        /// and localisation
        /// </history>
        /// -----------------------------------------------------------------------------
        private void Page_Load(object sender, EventArgs e)
        {
            try
            {
                this.valStreet.ErrorMessage = DotNetNuke.Services.Localization.Localization.GetString("StreetRequired", DotNetNuke.Services.Localization.Localization.GetResourceFile(this, this.MyFileName));
                this.valCity.ErrorMessage = DotNetNuke.Services.Localization.Localization.GetString("CityRequired", DotNetNuke.Services.Localization.Localization.GetResourceFile(this, this.MyFileName));
                this.valCountry.ErrorMessage = DotNetNuke.Services.Localization.Localization.GetString("CountryRequired", DotNetNuke.Services.Localization.Localization.GetResourceFile(this, this.MyFileName));
                this.valPostal.ErrorMessage = DotNetNuke.Services.Localization.Localization.GetString("PostalRequired", DotNetNuke.Services.Localization.Localization.GetResourceFile(this, this.MyFileName));
                this.valTelephone.ErrorMessage = DotNetNuke.Services.Localization.Localization.GetString("TelephoneRequired", DotNetNuke.Services.Localization.Localization.GetResourceFile(this, this.MyFileName));
                this.valCell.ErrorMessage = DotNetNuke.Services.Localization.Localization.GetString("CellRequired", DotNetNuke.Services.Localization.Localization.GetResourceFile(this, this.MyFileName));
                this.valFax.ErrorMessage = DotNetNuke.Services.Localization.Localization.GetString("FaxRequired", DotNetNuke.Services.Localization.Localization.GetResourceFile(this, this.MyFileName));
                if (this.Page.IsPostBack)
                {
                    return;
                }
                if (this._LabelColumnWidth != "")
                {
                }
                if (this._ControlColumnWidth != "")
                {
                    this.cboCountry.Width = System.Web.UI.WebControls.Unit.Parse(this._ControlColumnWidth);
                    this.cboRegion.Width = System.Web.UI.WebControls.Unit.Parse(this._ControlColumnWidth);
                    this.txtRegion.Width = System.Web.UI.WebControls.Unit.Parse(this._ControlColumnWidth);
                    this.txtCity.Width = System.Web.UI.WebControls.Unit.Parse(this._ControlColumnWidth);
                    this.txtStreet.Width = System.Web.UI.WebControls.Unit.Parse(this._ControlColumnWidth);
                    this.txtUnit.Width = System.Web.UI.WebControls.Unit.Parse(this._ControlColumnWidth);
                    this.txtPostal.Width = System.Web.UI.WebControls.Unit.Parse(this._ControlColumnWidth);
                    this.txtTelephone.Width = System.Web.UI.WebControls.Unit.Parse(this._ControlColumnWidth);
                    this.txtCell.Width = System.Web.UI.WebControls.Unit.Parse(this._ControlColumnWidth);
                    this.txtFax.Width = System.Web.UI.WebControls.Unit.Parse(this._ControlColumnWidth);
                }
                this.txtStreet.TabIndex = Convert.ToInt16(this._StartTabIndex);
                this.txtUnit.TabIndex = Convert.ToInt16((int) (this._StartTabIndex + 1));
                this.txtCity.TabIndex = Convert.ToInt16((int) (this._StartTabIndex + 2));
                this.cboCountry.TabIndex = Convert.ToInt16((int) (this._StartTabIndex + 3));
                this.cboRegion.TabIndex = Convert.ToInt16((int) (this._StartTabIndex + 4));
                this.txtRegion.TabIndex = Convert.ToInt16((int) (this._StartTabIndex + 5));
                this.txtPostal.TabIndex = Convert.ToInt16((int) (this._StartTabIndex + 6));
                this.txtTelephone.TabIndex = Convert.ToInt16((int) (this._StartTabIndex + 7));
                this.txtCell.TabIndex = Convert.ToInt16((int) (this._StartTabIndex + 8));
                this.txtFax.TabIndex = Convert.ToInt16((int) (this._StartTabIndex + 9));
                ListEntryInfoCollection entryCollection = new ListController().GetListEntryInfoCollection("Country");
                this.cboCountry.DataSource = entryCollection;
                this.cboCountry.DataBind();
                this.cboCountry.Items.Insert(0, new ListItem("<" + DotNetNuke.Services.Localization.Localization.GetString("Not_Specified", "~/App_GlobalResources/SharedResources.resx") + ">", ""));
                string refStringHelperL0 = Strings.LCase(this._CountryData);
                if (refStringHelperL0 == "text")
                {
                    if (this._Country == "")
                    {
                        this.cboCountry.SelectedIndex = 0;
                    }
                    else if (this.cboCountry.Items.FindByText(this._Country) != null)
                    {
                        this.cboCountry.ClearSelection();
                        this.cboCountry.Items.FindByText(this._Country).Selected = true;
                    }
                }
                else if ((refStringHelperL0 == "value") && (this.cboCountry.Items.FindByValue(this._Country) != null))
                {
                    this.cboCountry.ClearSelection();
                    this.cboCountry.Items.FindByValue(this._Country).Selected = true;
                }
                this.Localize();
                if (this.cboRegion.Visible)
                {
                    switch (Strings.LCase(this._RegionData))
                    {
                        case "text":
                            if (this._Region == "")
                            {
                                this.cboRegion.SelectedIndex = 0;
                            }
                            else if (this.cboRegion.Items.FindByText(this._Region) != null)
                            {
                                this.cboRegion.Items.FindByText(this._Region).Selected = true;
                            }
                            goto Label_05A7;

                        case "value":
                            if (this.cboRegion.Items.FindByValue(this._Region) != null)
                            {
                                this.cboRegion.Items.FindByValue(this._Region).Selected = true;
                            }
                            break;
                    }
                }
                else
                {
                    this.txtRegion.Text = this._Region;
                }
            Label_05A7:
                this.txtStreet.Text = this._Street;
                this.txtUnit.Text = this._Unit;
                this.txtCity.Text = this._City;
                this.txtPostal.Text = this._Postal;
                this.txtTelephone.Text = this._Telephone;
                this.txtCell.Text = this._Cell;
                this.txtFax.Text = this._Fax;
                this.rowStreet.Visible = this._ShowStreet;
                this.rowUnit.Visible = this._ShowUnit;
                this.rowCity.Visible = this._ShowCity;
                this.rowCountry.Visible = this._ShowCountry;
                this.rowRegion.Visible = this._ShowRegion;
                this.rowPostal.Visible = this._ShowPostal;
                this.rowTelephone.Visible = this._ShowTelephone;
                this.rowCell.Visible = this._ShowCell;
                this.rowFax.Visible = this._ShowFax;
                if (PortalSecurity.IsInRoles(this.PortalSettings.AdministratorRoleName))
                {
                    this.chkStreet.Visible = true;
                    this.chkCity.Visible = true;
                    this.chkCountry.Visible = true;
                    this.chkRegion.Visible = true;
                    this.chkPostal.Visible = true;
                    this.chkTelephone.Visible = true;
                    this.chkCell.Visible = true;
                    this.chkFax.Visible = true;
                }
                this.ViewState["ModuleId"] = Convert.ToString(this._ModuleId);
                this.ViewState["LabelColumnWidth"] = this._LabelColumnWidth;
                this.ViewState["ControlColumnWidth"] = this._ControlColumnWidth;
                this.ShowRequiredFields();
            }
            catch (Exception exception1)
            {
                
                Exception exc = exception1;
                DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(this, exc);
                
            }
        }

        /// -----------------------------------------------------------------------------
        /// <summary>
        /// ShowRequiredFields sets up displaying which fields are required
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <history>
        /// [cnurse]	10/08/2004	Updated to reflect design changes for Help, 508 support
        /// and localisation
        /// </history>
        /// -----------------------------------------------------------------------------
        private void ShowRequiredFields()
        {
            Hashtable settings = PortalSettings.GetSiteSettings(this.PortalSettings.PortalId);
            this.lblStreetRequired.Text = Interaction.IIf(Conversions.ToString(settings["addressstreet"]) == "N", "", "*").ToString();
            this.lblCityRequired.Text = Interaction.IIf(Conversions.ToString(settings["addresscity"]) == "N", "", "*").ToString();
            this.lblCountryRequired.Text = Interaction.IIf(Conversions.ToString(settings["addresscountry"]) == "N", "", "*").ToString();
            this.lblRegionRequired.Text = Interaction.IIf(Conversions.ToString(settings["addressregion"]) == "N", "", "*").ToString();
            this.lblPostalRequired.Text = Interaction.IIf(Conversions.ToString(settings["addresspostal"]) == "N", "", "*").ToString();
            this.lblTelephoneRequired.Text = Interaction.IIf(Conversions.ToString(settings["addresstelephone"]) == "N", "", "*").ToString();
            this.lblCellRequired.Text = Interaction.IIf(Conversions.ToString(settings["addresscell"]) == "N", "", "*").ToString();
            this.lblFaxRequired.Text = Interaction.IIf(Conversions.ToString(settings["addressfax"]) == "N", "", "*").ToString();
            if (PortalSecurity.IsInRoles(this.PortalSettings.AdministratorRoleName))
            {
                if (this.lblCountryRequired.Text == "*")
                {
                    this.chkCountry.Checked = true;
                    this.valCountry.Enabled = true;
                }
                if (this.lblRegionRequired.Text == "*")
                {
                    this.chkRegion.Checked = true;
                    if (this.cboRegion.Visible)
                    {
                        this.valRegion1.Enabled = true;
                        this.valRegion2.Enabled = false;
                    }
                    else
                    {
                        this.valRegion1.Enabled = false;
                        this.valRegion2.Enabled = true;
                    }
                }
                if (this.lblCityRequired.Text == "*")
                {
                    this.chkCity.Checked = true;
                    this.valCity.Enabled = true;
                }
                if (this.lblStreetRequired.Text == "*")
                {
                    this.chkStreet.Checked = true;
                    this.valStreet.Enabled = true;
                }
                if (this.lblPostalRequired.Text == "*")
                {
                    this.chkPostal.Checked = true;
                    this.valPostal.Enabled = true;
                }
                if (this.lblTelephoneRequired.Text == "*")
                {
                    this.chkTelephone.Checked = true;
                    this.valTelephone.Enabled = true;
                }
                if (this.lblCellRequired.Text == "*")
                {
                    this.chkCell.Checked = true;
                    this.valCell.Enabled = true;
                }
                if (this.lblFaxRequired.Text == "*")
                {
                    this.chkFax.Checked = true;
                    this.valFax.Enabled = true;
                }
            }
            if (this.lblCountryRequired.Text == "")
            {
                this.valCountry.Enabled = false;
            }
            if (this.lblRegionRequired.Text == "")
            {
                this.valRegion1.Enabled = false;
                this.valRegion2.Enabled = false;
            }
            if (this.lblCityRequired.Text == "")
            {
                this.valCity.Enabled = false;
            }
            if (this.lblStreetRequired.Text == "")
            {
                this.valStreet.Enabled = false;
            }
            if (this.lblPostalRequired.Text == "")
            {
                this.valPostal.Enabled = false;
            }
            if (this.lblTelephoneRequired.Text == "")
            {
                this.valTelephone.Enabled = false;
            }
            if (this.lblCellRequired.Text == "")
            {
                this.valCell.Enabled = false;
            }
            if (this.lblFaxRequired.Text == "")
            {
                this.valFax.Enabled = false;
            }
        }

        /// -----------------------------------------------------------------------------
        /// <summary>
        /// UpdateRequiredFields updates which fields are required
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <history>
        /// [cnurse]	10/08/2004	Updated to reflect design changes for Help, 508 support
        /// and localisation
        /// </history>
        /// -----------------------------------------------------------------------------
        private void UpdateRequiredFields()
        {
            if (!this.chkCountry.Checked)
            {
                this.chkRegion.Checked = false;
            }
            PortalSettings.UpdatePortalSetting(this.PortalSettings.PortalId, "addressstreet", Interaction.IIf(this.chkStreet.Checked, "", "N").ToString());
            PortalSettings.UpdatePortalSetting(this.PortalSettings.PortalId, "addresscity", Interaction.IIf(this.chkCity.Checked, "", "N").ToString());
            PortalSettings.UpdatePortalSetting(this.PortalSettings.PortalId, "addresscountry", Interaction.IIf(this.chkCountry.Checked, "", "N").ToString());
            PortalSettings.UpdatePortalSetting(this.PortalSettings.PortalId, "addressregion", Interaction.IIf(this.chkRegion.Checked, "", "N").ToString());
            PortalSettings.UpdatePortalSetting(this.PortalSettings.PortalId, "addresspostal", Interaction.IIf(this.chkPostal.Checked, "", "N").ToString());
            PortalSettings.UpdatePortalSetting(this.PortalSettings.PortalId, "addresstelephone", Interaction.IIf(this.chkTelephone.Checked, "", "N").ToString());
            PortalSettings.UpdatePortalSetting(this.PortalSettings.PortalId, "addresscell", Interaction.IIf(this.chkCell.Checked, "", "N").ToString());
            PortalSettings.UpdatePortalSetting(this.PortalSettings.PortalId, "addressfax", Interaction.IIf(this.chkFax.Checked, "", "N").ToString());
            this.ShowRequiredFields();
        }

        protected virtual CountryListBox cboCountry
        {
           
            get
            {
                return this._cboCountry;
            }
            
            set
            {
                EventHandler handler = new EventHandler(this.cboCountry_SelectedIndexChanged);
                if (this._cboCountry != null)
                {
                    this._cboCountry.SelectedIndexChanged -= handler;
                }
                this._cboCountry = value;
                if (this._cboCountry != null)
                {
                    this._cboCountry.SelectedIndexChanged += handler;
                }
            }
        }

        protected virtual DropDownList cboRegion
        {
           
            get
            {
                return this._cboRegion;
            }
            
            set
            {
                this._cboRegion = value;
            }
        }

        public string Cell
        {
            get
            {
                return this.txtCell.Text;
            }
            set
            {
                this._Cell = value;
            }
        }

        protected virtual CheckBox chkCell
        {
           
            get
            {
                return this._chkCell;
            }
            
            set
            {
                EventHandler handler = new EventHandler(this.chkCell_CheckedChanged);
                if (this._chkCell != null)
                {
                    this._chkCell.CheckedChanged -= handler;
                }
                this._chkCell = value;
                if (this._chkCell != null)
                {
                    this._chkCell.CheckedChanged += handler;
                }
            }
        }

        protected virtual CheckBox chkCity
        {
           
            get
            {
                return this._chkCity;
            }
            
            set
            {
                EventHandler handler = new EventHandler(this.chkCity_CheckedChanged);
                if (this._chkCity != null)
                {
                    this._chkCity.CheckedChanged -= handler;
                }
                this._chkCity = value;
                if (this._chkCity != null)
                {
                    this._chkCity.CheckedChanged += handler;
                }
            }
        }

        protected virtual CheckBox chkCountry
        {
           
            get
            {
                return this._chkCountry;
            }
            
            set
            {
                EventHandler handler = new EventHandler(this.chkCountry_CheckedChanged);
                if (this._chkCountry != null)
                {
                    this._chkCountry.CheckedChanged -= handler;
                }
                this._chkCountry = value;
                if (this._chkCountry != null)
                {
                    this._chkCountry.CheckedChanged += handler;
                }
            }
        }

        protected virtual CheckBox chkFax
        {
           
            get
            {
                return this._chkFax;
            }
            
            set
            {
                EventHandler handler = new EventHandler(this.chkFax_CheckedChanged);
                if (this._chkFax != null)
                {
                    this._chkFax.CheckedChanged -= handler;
                }
                this._chkFax = value;
                if (this._chkFax != null)
                {
                    this._chkFax.CheckedChanged += handler;
                }
            }
        }

        protected virtual CheckBox chkPostal
        {
           
            get
            {
                return this._chkPostal;
            }
            
            set
            {
                EventHandler handler = new EventHandler(this.chkPostal_CheckedChanged);
                if (this._chkPostal != null)
                {
                    this._chkPostal.CheckedChanged -= handler;
                }
                this._chkPostal = value;
                if (this._chkPostal != null)
                {
                    this._chkPostal.CheckedChanged += handler;
                }
            }
        }

        protected virtual CheckBox chkRegion
        {
           
            get
            {
                return this._chkRegion;
            }
            
            set
            {
                EventHandler handler = new EventHandler(this.chkRegion_CheckedChanged);
                if (this._chkRegion != null)
                {
                    this._chkRegion.CheckedChanged -= handler;
                }
                this._chkRegion = value;
                if (this._chkRegion != null)
                {
                    this._chkRegion.CheckedChanged += handler;
                }
            }
        }

        protected virtual CheckBox chkStreet
        {
           
            get
            {
                return this._chkStreet;
            }
            
            set
            {
                EventHandler handler = new EventHandler(this.chkStreet_CheckedChanged);
                if (this._chkStreet != null)
                {
                    this._chkStreet.CheckedChanged -= handler;
                }
                this._chkStreet = value;
                if (this._chkStreet != null)
                {
                    this._chkStreet.CheckedChanged += handler;
                }
            }
        }

        protected virtual CheckBox chkTelephone
        {
           
            get
            {
                return this._chkTelephone;
            }
            
            set
            {
                EventHandler handler = new EventHandler(this.chkTelephone_CheckedChanged);
                if (this._chkTelephone != null)
                {
                    this._chkTelephone.CheckedChanged -= handler;
                }
                this._chkTelephone = value;
                if (this._chkTelephone != null)
                {
                    this._chkTelephone.CheckedChanged += handler;
                }
            }
        }

        public string City
        {
            get
            {
                return this.txtCity.Text;
            }
            set
            {
                this._City = value;
            }
        }

        public string ControlColumnWidth
        {
            get
            {
                return Convert.ToString(RuntimeHelpers.GetObjectValue(this.ViewState["ControlColumnWidth"]));
            }
            set
            {
                this._ControlColumnWidth = value;
            }
        }

        public string Country
        {
            get
            {
                if (this.cboCountry.SelectedItem != null)
                {
                    switch (Strings.LCase(this._CountryData))
                    {
                        case "text":
                            if (this.cboCountry.SelectedIndex == 0)
                            {
                                return "";
                            }
                            return this.cboCountry.SelectedItem.Text;

                        case "value":
                            return this.cboCountry.SelectedItem.Value;
                    }
                }
                return "";
            }
            set
            {
                this._Country = value;
            }
        }

        public string CountryData
        {
            set
            {
                this._CountryData = value;
            }
        }

        public string Fax
        {
            get
            {
                return this.txtFax.Text;
            }
            set
            {
                this._Fax = value;
            }
        }

        public string LabelColumnWidth
        {
            get
            {
                return Convert.ToString(RuntimeHelpers.GetObjectValue(this.ViewState["LabelColumnWidth"]));
            }
            set
            {
                this._LabelColumnWidth = value;
            }
        }

        public string LocalResourceFile
        {
            get
            {
                return DotNetNuke.Services.Localization.Localization.GetResourceFile(this, this.MyFileName);
            }
        }

        public int ModuleId
        {
            get
            {
                return Convert.ToInt32(RuntimeHelpers.GetObjectValue(this.ViewState["ModuleId"]));
            }
            set
            {
                this._ModuleId = value;
            }
        }

        public string Postal
        {
            get
            {
                return this.txtPostal.Text;
            }
            set
            {
                this._Postal = value;
            }
        }

        public string Region
        {
            get
            {
                string retValue = "";
                if (this.cboRegion.Visible)
                {
                    if (this.cboRegion.SelectedItem != null)
                    {
                        switch (Strings.LCase(this._RegionData))
                        {
                            case "text":
                                if (this.cboRegion.SelectedIndex > 0)
                                {
                                    retValue = this.cboRegion.SelectedItem.Text;
                                }
                                return retValue;

                            case "value":
                                retValue = this.cboRegion.SelectedItem.Value;
                                break;
                        }
                    }
                    return retValue;
                }
                return this.txtRegion.Text;
            }
            set
            {
                this._Region = value;
            }
        }

        public string RegionData
        {
            set
            {
                this._RegionData = value;
            }
        }

        public bool ShowCell
        {
            set
            {
                this._ShowCell = value;
            }
        }

        public bool ShowCity
        {
            set
            {
                this._ShowCity = value;
            }
        }

        public bool ShowCountry
        {
            set
            {
                this._ShowCountry = value;
            }
        }

        public bool ShowFax
        {
            set
            {
                this._ShowFax = value;
            }
        }

        public bool ShowPostal
        {
            set
            {
                this._ShowPostal = value;
            }
        }

        public bool ShowRegion
        {
            set
            {
                this._ShowRegion = value;
            }
        }

        public bool ShowStreet
        {
            set
            {
                this._ShowStreet = value;
            }
        }

        public bool ShowTelephone
        {
            set
            {
                this._ShowTelephone = value;
            }
        }

        public bool ShowUnit
        {
            set
            {
                this._ShowUnit = value;
            }
        }

        public int StartTabIndex
        {
            set
            {
                this._StartTabIndex = value;
            }
        }

        public string Street
        {
            get
            {
                return this.txtStreet.Text;
            }
            set
            {
                this._Street = value;
            }
        }

        public string Telephone
        {
            get
            {
                return this.txtTelephone.Text;
            }
            set
            {
                this._Telephone = value;
            }
        }

        public string Unit
        {
            get
            {
                return this.txtUnit.Text;
            }
            set
            {
                this._Unit = value;
            }
        }
    }
}

